import { PickerView } from "antd-mobile";
import React, { Component } from "react";

import FilterFooter from '../../../../components/FilterFooter'

import styles from './index.module.css'

export default class FilterPicker extends Component {
  constructor(props) {
    super(props)
    this.state = {
      value: props.value
    }
  }

  render() {
    let { filterData, type, cols, onCancel, onSave } = this.props
    let { value } = this.state

    return (
      <div className={styles.picker}>
        <PickerView
          data={filterData}
          value={value}
          cols={cols}
          onChange={val => {
            this.setState({
              value: val
            })
          }}
        />
        <FilterFooter ok="确定" cancel="取消" onCancel={() => onCancel(type)} onSave={() => onSave(type, value)}/>
      </div>
    )
  }
}
